package cur.nature.component.redis;

import cur.nature.framework.core.log.LOG;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.event.ContextClosedEvent;

@Configuration
@ConditionalOnProperty( value = {"cur.component.redis.enable"})
public class RedisListener {

    @Bean
    public ApplicationListener onRedisStart() {
        return (ApplicationListener<ApplicationReadyEvent>) event -> {
            LOG.info("Redis started-------------------------------");
        };
    };

    @Bean
    public ApplicationListener onRedisStop() {
        return (ApplicationListener<ContextClosedEvent>) event -> {
            LOG.info("Redis stopped-------------------------------");
        };
    }
}
